//
//  Status.swift
//  JLWeibo
//
//  Created by sunjinliang on 15/12/10.
//  Copyright © 2015年 sunjinliang. All rights reserved.
//

import UIKit

class Status: NSObject {
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 用户模型
    var user: User?
    /// 配图
    var pic_urls: [[String: String]]?
    var retweeted_status: Status?
   
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user"{
            if let dict = value as? [String : AnyObject]{
                user = User(dict: dict)
            }
            return
        }
        if key == "retweeted_status"{
            
            guard let dict = value as? [String: AnyObject] else{
                print("retweeted_status格式转化错误")
                return
            }
            retweeted_status = Status(dict: dict)
            return
        }
        
        super.setValue(value, forKey: key)
    }
    override var description: String {
        let keys = ["id", "text","created_at", "source", "user","pic_urls"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
